﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using PJ.Admin.Models;
using PJ.DBModel.Models;
using PJ.IService;
using PJ.UnitOfWork;

namespace PJ.Admin.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        private IUnitOfWork<zlwebContext> _unitOfWork;

        private IEnumerable<ITestService> _testService;

        public HomeController(ILogger<HomeController> logger, IEnumerable<ITestService> testService, IUnitOfWork<zlwebContext> unitOfWork)
        {
            _logger = logger;
            _testService = testService;
            _unitOfWork = unitOfWork;
        }

        public IActionResult Index()
        {

            //var dddd = _testService.Where(q => q.ModelType == "Class1").FirstOrDefault();
            //foreach (var item in _testService)
            //{
            //    var abc = item.Test();
            //}
            var tt = (from a in _unitOfWork.DbContext.Button
                      join b in _unitOfWork.DbContext.Donation on a.Id equals b.Id
                      select new { a.Id, a.Location }).ToList();

            return View();
        }

        public IActionResult Main()
        {
            return View();
        }

        public IActionResult Main2()
        {
            return View();
        }
        public IActionResult Main3()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
